<!DOCTYPE HTML>
<html lang="zh-CN">


<head><meta name="generator" content="Hexo 3.8.0">
    <meta charset="utf-8">
    <meta name="keywords" content="Class解读, Swift, iOS, Python">
    <meta name="description" content="群组欢迎加入群组,闲聊工作&amp;amp;技术&amp;amp;问题等

类的声明首先我们在runtime.h文件中看到objc_class的结构声明:

/// 类的声明结构

struct objc_class {

Class _Nonnull i">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>Class解读 | waitwalker</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">
    <style type="text/css">
        
    </style>

    <script src="/libs/jquery/jquery-2.2.0.min.js"></script>
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>


<body>

<!--导航-->

<header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    <!---->
                    <!--<img src="/medias/logo.png" class="logo-img" alt="LOGO">-->
                    <!---->
                    <span class="logo-span">waitwalker</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fa fa-navicon"></i></a>
<ul class="right">
    
    <li class="hide-on-med-and-down">
        <a href="/" class="waves-effect waves-light">
            
            <i class="fa fa-home"></i>
            
            <span>首页</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/tags" class="waves-effect waves-light">
            
            <i class="fa fa-tags"></i>
            
            <span>标签</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/categories" class="waves-effect waves-light">
            
            <i class="fa fa-bookmark"></i>
            
            <span>分类</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/archives" class="waves-effect waves-light">
            
            <i class="fa fa-archive"></i>
            
            <span>归档</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/about" class="waves-effect waves-light">
            
            <i class="fa fa-user-circle-o"></i>
            
            <span>关于</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/friends" class="waves-effect waves-light">
            
            <i class="fa fa-address-book"></i>
            
            <span>友情链接</span>
        </a>
    </li>
    
    <li>
        <a href="#searchModal" class="modal-trigger waves-effect waves-light">
            <i id="searchIcon" class="fa fa-search" title="搜索"></i>
        </a>
    </li>
</ul>

<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">waitwalker</div>
        <div class="logo-desc">
            
            Life is measured by thought and action not by time.
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li>
            <a href="/" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-home"></i>
                
                首页
            </a>
        </li>
        
        <li>
            <a href="/tags" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-tags"></i>
                
                标签
            </a>
        </li>
        
        <li>
            <a href="/categories" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-bookmark"></i>
                
                分类
            </a>
        </li>
        
        <li>
            <a href="/archives" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-archive"></i>
                
                归档
            </a>
        </li>
        
        <li>
            <a href="/about" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-user-circle-o"></i>
                
                关于
            </a>
        </li>
        
        <li>
            <a href="/friends" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-address-book"></i>
                
                友情链接
            </a>
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/waitwalker" class="waves-effect waves-light" target="_blank">
                <i class="fa fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>

        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/waitwalker" class="github-corner tooltipped hide-on-med-and-down" target="_blank" data-tooltip="https://github.com/waitwalker" data-position="left" data-delay="50">
    <svg viewbox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"/>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"/>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"/>
    </svg>
</a>
        
    </nav>

</header>





<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/16.jpg')">
    <div class="container">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <div class="description center-align post-title">
                        Class解读
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #toc-content .is-active-link::before {
        background-color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 20px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/Runtime/" target="_blank">
                                <span class="chip bg-color">Runtime</span>
                            </a>
                        
                            <a href="/tags/底层/" target="_blank">
                                <span class="chip bg-color">底层</span>
                            </a>
                        
                            <a href="/tags/源码/" target="_blank">
                                <span class="chip bg-color">源码</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fa fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/categories/Runtime源码解读/" class="post-category" target="_blank">
                                Runtime源码解读
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                <div class="post-date info-break-policy">
                    <i class="fa fa-calendar-minus-o fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2019-04-15
                </div>

                
				
				
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="fa fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>
        </div>
        <hr class="clearfix">
        <div class="card-content article-card-content">
            <div id="articleContent">
                <p><strong>群组</strong><br><strong>欢迎加入群组,闲聊工作&amp;技术&amp;问题等</strong></p>
<p><img src="https://github.com/waitwalker/Resources/blob/master/Flutter/group/flutter_development_0923.JPG?raw=true" width="350" height="480" align="center"></p>
<h4 id="类的声明"><a href="#类的声明" class="headerlink" title="类的声明"></a>类的声明</h4><p>首先我们在runtime.h文件中看到objc_class的结构声明:</p>
<pre><code>
/// 类的声明结构

struct objc_class {

Class _Nonnull isa OBJC_ISA_AVAILABILITY;//isa 指针

#if !__OBJC2__

Class _Nullable super_class OBJC2_UNAVAILABLE;//指向父类的指针

const char * _Nonnull name OBJC2_UNAVAILABLE;//类名

long version OBJC2_UNAVAILABLE;//版本

long info OBJC2_UNAVAILABLE;//其它信息

long instance_size OBJC2_UNAVAILABLE;//实例变量空间大小

struct objc_ivar_list * _Nullable ivars OBJC2_UNAVAILABLE;//成员变量列表

struct objc_method_list * _Nullable * _Nullable methodLists OBJC2_UNAVAILABLE;//方法列表

struct objc_cache * _Nonnull cache OBJC2_UNAVAILABLE;//方法缓存列表

struct objc_protocol_list * _Nullable protocols OBJC2_UNAVAILABLE;//协议列表

#endif

} OBJC2_UNAVAILABLE;

/* Use `Class` instead of `struct objc_class *` */

</code></pre><p>以上是runtime暴露给我们的有关Class的接口,而在objc-runtime-new.h文件中有objc_class结构的完整声明:</p>
<pre><code>
// MARK: - class的完整声明结构

struct objc_class : objc_object {

// Class ISA;

Class superclass;//指向父类指针

cache_t cache; // formerly cache pointer and vtable //缓存一些指针和虚表

class_data_bits_t bits; // class_rw_t * plus custom rr/alloc flags // 含有class_rw_t,内部存储方法,属性,遵循的协议等

// class_rw_t指针

class_rw_t *data() {

return bits.data();

}

// set bits

void setData(class_rw_t *newData) {

bits.setData(newData);

}

...下面未列出

}

</code></pre><p>可以看出,objc_class中有几个比较重要的成员变量和函数:</p>
<h5 id="superclass"><a href="#superclass" class="headerlink" title="superclass"></a><strong>superclass</strong></h5><p>指向父类的指针</p>
<h5 id="cache-t"><a href="#cache-t" class="headerlink" title="cache_t"></a><strong>cache_t</strong></h5><p>cache里面存的是指针和虚表,为了方法调用时,快速查询,提高效率.其结构声明如下:</p>
<pre><code>
// MARK: - cache_t结构声明

struct cache_t {

struct bucket_t *_buckets;

mask_t _mask;

mask_t _occupied;

...下面未列出

}

</code></pre><h6 id="bucket-t"><a href="#bucket-t" class="headerlink" title="bucket_t"></a>bucket_t</h6><pre><code>
// MARK: - bucket_t声明结构

struct bucket_t {

private:

// IMP-first is better for arm64e ptrauth and no worse for arm64.

// SEL-first is better for armv7* and i386 and x86_64.

#if __arm64__

MethodCacheIMP _imp;

cache_key_t _key;

#else

cache_key_t _key;

MethodCacheIMP _imp;

#endif

public:

inline cache_key_t key() const { return _key; }

inline IMP imp() const { return (IMP)_imp; }

inline void setKey(cache_key_t newKey) { _key = newKey; }

inline void setImp(IMP newImp) { _imp = newImp; }

void set(cache_key_t newKey, IMP newImp);

};

</code></pre><p>这个bucket_t类似于一个hash表,其没一个cache_key_t对应一个imp.其关系如下图:</p>
<p><img src="http://upload-images.jianshu.io/upload_images/1715253-2f6f114a344d02ac.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="bucket_t"></p>
<h5 id="class-data-bits-t结构"><a href="#class-data-bits-t结构" class="headerlink" title="class_data_bits_t结构"></a><strong>class_data_bits_t结构</strong></h5><pre><code>
// MARK: - class_data_bits_t声明结构

struct class_data_bits_t {

class_rw_t* data() {

return (class_rw_t *)(bits &amp; FAST_DATA_MASK);

}

void setData(class_rw_t *newData)

{

assert(!data() || (newData-&gt;flags &amp; (RW_REALIZING | RW_FUTURE)));

// Set during realization or construction only. No locking needed.

// Use a store-release fence because there may be concurrent

// readers of data and data&#39;s contents.

uintptr_t newBits = (bits &amp; ~FAST_DATA_MASK) | (uintptr_t)newData;

atomic_thread_fence(memory_order_release);

bits = newBits;

}

...其它未列出

}

</code></pre><p>class_data_bits_t中成员函数 data()函数,返回一个class_rw_t结构指针;</p>
<h5 id="class-rw-t"><a href="#class-rw-t" class="headerlink" title="class_rw_t"></a><strong>class_rw_t</strong></h5><pre><code>
// MARK: - class_rw_t结构声明

struct class_rw_t {

// Be warned that Symbolication knows the layout of this structure.

uint32_t flags;

uint32_t version;

const class_ro_t *ro;

method_array_t methods;

property_array_t properties;

protocol_array_t protocols;

Class firstSubclass;

Class nextSiblingClass;

char *demangledName;

#if SUPPORT_INDEXED_ISA

uint32_t index;

#endif

void setFlags(uint32_t set)

{

OSAtomicOr32Barrier(set, &amp;flags);

}

void clearFlags(uint32_t clear)

{

OSAtomicXor32Barrier(clear, &amp;flags);

}

// set and clear must not overlap

void changeFlags(uint32_t set, uint32_t clear)

{

assert((set &amp; clear) == 0);

uint32_t oldf, newf;

do {

oldf = flags;

newf = (oldf | set) &amp; ~clear;

} while (!OSAtomicCompareAndSwap32Barrier(oldf, newf, (volatile int32_t *)&amp;flags));

}

};

</code></pre><p>class_rw_t中的成员变量class_ro_t:</p>
<h5 id="class-ro-t"><a href="#class-ro-t" class="headerlink" title="class_ro_t"></a><strong>class_ro_t</strong></h5><pre><code>
// MARK: - class_ro_t结构声明

struct class_ro_t {

uint32_t flags;

uint32_t instanceStart;

uint32_t instanceSize;

#ifdef __LP64__

uint32_t reserved;

#endif

const uint8_t * ivarLayout;

const char * name;

method_list_t * baseMethodList;

protocol_list_t * baseProtocols;

const ivar_list_t * ivars;

const uint8_t * weakIvarLayout;

property_list_t *baseProperties;

method_list_t *baseMethods() const {

return baseMethodList;

}

};

</code></pre><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class_ro_t有method_list_t,protocol_list_t,ivar_list_t,property_list_t等成员变量这些成员变量的作用是存储编译后已确定的一些信息.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class_rw_t中同样有method_array_t(方法列表),property_array_t(属性列表),protocol_array_t(协议列表),这三者均继承自list_array_tt,list_array_tt可以扩充,内部分别存储的是method_list_t,property_list_t和protocol_list_t;这个三个成员变量主要是方便在运行时为类提供拓展能力.</p>
<h4 id="编译后class内存布局"><a href="#编译后class内存布局" class="headerlink" title="编译后class内存布局"></a>编译后class内存布局</h4><pre><code>
// Person

#import &lt;Foundation/Foundation.h&gt;

NS_ASSUME_NONNULL_BEGIN

@interface Person : NSObject

- (void)name;

@end

NS_ASSUME_NONNULL_END

int main(int argc, const char * argv[]) {

@autoreleasepool {

Class newClass = objc_allocateClassPair(objc_getClass(&quot;NSObject&quot;), &quot;newClass&quot;, 0);

objc_registerClassPair(newClass);

id newObject = [[newClass alloc]init];

NSLog(@&quot;%s&quot;,class_getName([newObject class]));

NSLog(@&quot;Hello, World!&quot;);

Person *person = [Person new];

[person name];

[person name];

Class cls = [Person class];

}

return 0;

}

</code></pre><p>我们来看cls这个class在编译后的内存布局,首先我们在main入口函数里面继续初始化一个Class cls = [Person class];然后运行一下获取当前cls的内存地址,然后将断点放过.</p>
<p><img src="http://upload-images.jianshu.io/upload_images/1715253-5d0150be3d085679.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="Person class address"></p>
<p>然后在_objc_init()函数(runtime初始化之前)加一个断点:</p>
<p><img src="http://upload-images.jianshu.io/upload_images/1715253-11a62e46db779044.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="_objc_init()"></p>
<p>用lldb命令调试一下:</p>
<p><img src="http://upload-images.jianshu.io/upload_images/1715253-ca7a1d8cedf5f4bb.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="cls memory layout"></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;通过上图我们可以看到,name(“Person”)和baseMethodList这两个是有值,其它都为0x0000000000000000空指针,这个也反映出我们在Person中的最初定义:只有一个- (void)name方法,没有协议,成员变量,属性等.</p>
<p>我们从baseMethodList方法列表中第一个method_t</p>
<p><img src="http://upload-images.jianshu.io/upload_images/1715253-2cdabc19c9ae5403.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="name func"></p>
<p>这个method_t正好对应我们定义的name方法;而baseMethodList里面也就有1个方法:</p>
<p><img src="http://upload-images.jianshu.io/upload_images/1715253-562d498710ddaf8e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="baseMethodList count"></p>
<h4 id="类的实现realizeClass"><a href="#类的实现realizeClass" class="headerlink" title="类的实现realizeClass"></a>类的实现realizeClass</h4><p>realizeClass是类初始化函数,类的运行时初始化都要调用此函数.</p>
<pre><code>
// MARK: - 类的初始化

/***********************************************************************

* realizeClass

* Performs first-time initialization on class cls,

* including allocating its read-write data.

* Returns the real class structure for the class.

* Locking: runtimeLock must be write-locked by the caller

**********************************************************************/

static Class realizeClass(Class cls)

{

runtimeLock.assertLocked();

const class_ro_t *ro;

class_rw_t *rw;

Class supercls;

Class metacls;

bool isMeta;

if (!cls) return nil;

if (cls-&gt;isRealized()) return cls;

assert(cls == remapClass(cls));

// fixme verify class is not in an un-dlopened part of the shared cache?

ro = (const class_ro_t *)cls-&gt;data();

if (ro-&gt;flags &amp; RO_FUTURE) {

// This was a future class. rw data is already allocated.

rw = cls-&gt;data();

ro = cls-&gt;data()-&gt;ro;

cls-&gt;changeInfo(RW_REALIZED|RW_REALIZING, RW_FUTURE);

} else {

// Normal class. Allocate writeable class data.

rw = (class_rw_t *)calloc(sizeof(class_rw_t), 1);

rw-&gt;ro = ro;

rw-&gt;flags = RW_REALIZED|RW_REALIZING;

cls-&gt;setData(rw);

}

isMeta = ro-&gt;flags &amp; RO_META;

rw-&gt;version = isMeta ? 7 : 0; // old runtime went up to 6

// Choose an index for this class.

// Sets cls-&gt;instancesRequireRawIsa if indexes no more indexes are available

cls-&gt;chooseClassArrayIndex();

if (PrintConnecting) {

_objc_inform(&quot;CLASS: realizing class &#39;%s&#39;%s %p %p #%u&quot;,

cls-&gt;nameForLogging(), isMeta ? &quot; (meta)&quot; : &quot;&quot;,

(void*)cls, ro, cls-&gt;classArrayIndex());

}

// Realize superclass and metaclass, if they aren&#39;t already.

// This needs to be done after RW_REALIZED is set above, for root classes.

// This needs to be done after class index is chosen, for root metaclasses.

supercls = realizeClass(remapClass(cls-&gt;superclass));

metacls = realizeClass(remapClass(cls-&gt;ISA()));

#if SUPPORT_NONPOINTER_ISA

// Disable non-pointer isa for some classes and/or platforms.

// Set instancesRequireRawIsa.

bool instancesRequireRawIsa = cls-&gt;instancesRequireRawIsa();

bool rawIsaIsInherited = false;

static bool hackedDispatch = false;

if (DisableNonpointerIsa) {

// Non-pointer isa disabled by environment or app SDK version

instancesRequireRawIsa = true;

}

else if (!hackedDispatch &amp;&amp; !(ro-&gt;flags &amp; RO_META) &amp;&amp;

0 == strcmp(ro-&gt;name, &quot;OS_object&quot;))

{

// hack for libdispatch et al - isa also acts as vtable pointer

hackedDispatch = true;

instancesRequireRawIsa = true;

}

else if (supercls &amp;&amp; supercls-&gt;superclass &amp;&amp;

supercls-&gt;instancesRequireRawIsa())

{

// This is also propagated by addSubclass()

// but nonpointer isa setup needs it earlier.

// Special case: instancesRequireRawIsa does not propagate

// from root class to root metaclass

instancesRequireRawIsa = true;

rawIsaIsInherited = true;

}

if (instancesRequireRawIsa) {

cls-&gt;setInstancesRequireRawIsa(rawIsaIsInherited);

}

// SUPPORT_NONPOINTER_ISA

#endif

// Update superclass and metaclass in case of remapping

cls-&gt;superclass = supercls;

cls-&gt;initClassIsa(metacls);

// Reconcile instance variable offsets / layout.

// This may reallocate class_ro_t, updating our ro variable.

if (supercls &amp;&amp; !isMeta) reconcileInstanceVariables(cls, supercls, ro);

// Set fastInstanceSize if it wasn&#39;t set already.

cls-&gt;setInstanceSize(ro-&gt;instanceSize);

// Copy some flags from ro to rw

if (ro-&gt;flags &amp; RO_HAS_CXX_STRUCTORS) {

cls-&gt;setHasCxxDtor();

if (! (ro-&gt;flags &amp; RO_HAS_CXX_DTOR_ONLY)) {

cls-&gt;setHasCxxCtor();

}

}

// Connect this class to its superclass&#39;s subclass lists

if (supercls) {

addSubclass(supercls, cls);

} else {

addRootClass(cls);

}

// Attach categories

methodizeClass(cls);

return cls;

}

</code></pre><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;下面我们来验证class_ro_t确定时机.还是之前的步骤,先编译一次获取到cls的内存地址.在static Class realizeClass(Class cls){}入口添加一个条件断点,运行:</p>
<p><img src="http://upload-images.jianshu.io/upload_images/1715253-4eeb6440a9f42fb3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="condition breakpoint"></p>
<p>然后lldb调试cls:</p>
<p>访问 class_data_bits_t 指针的内容:(class_data_bits_t) $2755 = (bits = 4294971696)</p>
<p>获取 class_rw_t:</p>
<pre><code>
(class_rw_t) $2757 = {

flags = 128

version = 8

ro = 0x0000000000000008

methods = {

list_array_tt&lt;method_t, method_list_t&gt; = {

= {

list = 0x0000000000000000

arrayAndFlag = 0

}

}

}

properties = {

list_array_tt&lt;property_t, property_list_t&gt; = {

= {

list = 0x0000000100000f84

arrayAndFlag = 4294971268

}

}

}

protocols = {

list_array_tt&lt;unsigned long, protocol_list_t&gt; = {

= {

list = 0x0000000100001110

arrayAndFlag = 4294971664

}

}

}

firstSubclass = nil

nextSiblingClass = nil

demangledName = 0x0000000000000000 &lt;no value available&gt;

}

</code></pre><p><img src="http://upload-images.jianshu.io/upload_images/1715253-aac44a322f04f552.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="class_rw_t"></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;我们可以看到class_rw_t中的成员变量ro = 0x0000000000000008在运行前已经有值了.获取一下ro:</p>
<pre><code>
(lldb) p $2757.ro

(const class_ro_t *) $2758 = 0x0000000000000008

</code></pre><p>由于lldb输出class_ro_t报错:</p>
<pre><code>
(lldb) p *$2758

error: Couldn&#39;t apply expression side effects : Couldn&#39;t dematerialize a result variable: couldn&#39;t read its memory

</code></pre><p>我们直接单步断点,往下走两步,直接获取ro的值:</p>
<p><img src="http://upload-images.jianshu.io/upload_images/1715253-db5d8af8cabe5ec5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="class_ro_t"></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;我们发现const指针 class_ro_t已经在编译期把类的相关信息(方法,属性,成员变量,协议)确定了.而类的初始化方法执行之后,编译期的ro赋值给了运行期的rw的成员变量ro了.</p>
<pre><code>
ro = (const class_ro_t *)cls-&gt;data();

if (ro-&gt;flags &amp; RO_FUTURE) {

// This was a future class. rw data is already allocated.

rw = cls-&gt;data();

ro = cls-&gt;data()-&gt;ro;

cls-&gt;changeInfo(RW_REALIZED|RW_REALIZING, RW_FUTURE);

} else {

// 将ro等信息赋值给class_rw_t

// Normal class. Allocate writeable class data.

rw = (class_rw_t *)calloc(sizeof(class_rw_t), 1);

rw-&gt;ro = ro;

rw-&gt;flags = RW_REALIZED|RW_REALIZING;

cls-&gt;setData(rw);

}

</code></pre><p>我们知道class_rw_t中除了class_ro_t成员变量外,还有以下三个成员变量:</p>
<pre><code>
method_array_t methods;

property_array_t properties;

protocol_array_t protocols;

</code></pre><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;这三个成员变量的赋值操作在static void methodizeClass(Class cls)()函数中,分别遍历ro中的方法,协议,属性列表分别加入到class_rw_t的methods,protocols,properties中.</p>
<pre><code>
// MARK: - 将ro中的方法,属性,协议等列表添加到rw中对应的三个成员变量列表中

/***********************************************************************

* methodizeClass

* Fixes up cls&#39;s method list, protocol list, and property list.

* Attaches any outstanding categories.

* Locking: runtimeLock must be held by the caller

**********************************************************************/

static void methodizeClass(Class cls)

{

runtimeLock.assertLocked();

bool isMeta = cls-&gt;isMetaClass();

auto rw = cls-&gt;data();

auto ro = rw-&gt;ro;

// Methodizing for the first time

if (PrintConnecting) {

_objc_inform(&quot;CLASS: methodizing class &#39;%s&#39; %s&quot;,

cls-&gt;nameForLogging(), isMeta ? &quot;(meta)&quot; : &quot;&quot;);

}

// 遍历ro中方法将其加入到rw methods中

// Install methods and properties that the class implements itself.

method_list_t *list = ro-&gt;baseMethods();

if (list) {

prepareMethodLists(cls, &amp;list, 1, YES, isBundleClass(cls));

rw-&gt;methods.attachLists(&amp;list, 1);

}

// 遍历ro中属性列表将其加入到 rw properties中

property_list_t *proplist = ro-&gt;baseProperties;

if (proplist) {

rw-&gt;properties.attachLists(&amp;proplist, 1);

}

// 遍历ro中协议列表将其加入到 rw protocols中

protocol_list_t *protolist = ro-&gt;baseProtocols;

if (protolist) {

rw-&gt;protocols.attachLists(&amp;protolist, 1);

}

// Root classes get bonus method implementations if they don&#39;t have

// them already. These apply before category replacements.

if (cls-&gt;isRootMetaclass()) {

// root metaclass

addMethod(cls, SEL_initialize, (IMP)&amp;objc_noop_imp, &quot;&quot;, NO);

}

// Attach categories.

category_list *cats = unattachedCategoriesForClass(cls, true /*realizing*/);

attachCategories(cls, cats, false /*don&#39;t flush caches*/);

if (PrintConnecting) {

if (cats) {

for (uint32_t i = 0; i &lt; cats-&gt;count; i++) {

_objc_inform(&quot;CLASS: attached category %c%s(%s)&quot;,

isMeta ? &#39;+&#39; : &#39;-&#39;,

cls-&gt;nameForLogging(), cats-&gt;list[i].cat-&gt;name);

}

}

}

if (cats) free(cats);

#if DEBUG

// Debug: sanity-check all SELs; log method list contents

for (const auto&amp; meth : rw-&gt;methods) {

if (PrintConnecting) {

_objc_inform(&quot;METHOD %c[%s %s]&quot;, isMeta ? &#39;+&#39; : &#39;-&#39;,

cls-&gt;nameForLogging(), sel_getName(meth.name));

}

assert(sel_registerName(sel_getName(meth.name)) == meth.name);

}

#endif

}

</code></pre><h4 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h4><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;编译期:通过objc_class-&gt;data()获取class_ro_t,class的method,property,protocol,ivar等已确定被赋值给class_ro_t,class_to_t只读,说明编译期类的内存布局已固定.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;运行期:通过realizeClass()类初始化函数,给class_rw_t分配空间,将class_ro_t赋值给class_rw_t的成员变量ro.将ro中的方法,协议,属性列表分别加入到class_rw_t的methods,protocols,properties中.class_rw_t提供了运行期这些成员变量的扩展性.</p>
<h3 id="编译后源码库"><a href="#编译后源码库" class="headerlink" title="编译后源码库"></a>编译后源码库</h3><p><strong>编译后的源码放在<a href="https://github.com/waitwalker/Runtime" target="_blank" rel="noopener">Github</a>, 如果对你有帮助,请给一个star吧!</strong></p>
<h3 id="博客地址-amp-相关文章"><a href="#博客地址-amp-相关文章" class="headerlink" title="博客地址&amp;相关文章"></a>博客地址&amp;相关文章</h3><p><strong>博客地址:</strong> <a href="https://waitwalker.github.io/">https://waitwalker.github.io/</a></p>
<p>系列文章:</p>
<p><a href="https://waitwalker.github.io/2019/04/08/Runtime%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91/">1. Runtime源码编译</a></p>
<p><a href="https://waitwalker.github.io/2019/04/10/objc-object%E8%A7%A3%E8%AF%BB/">2. objc_object解读</a></p>
<p><a href="https://waitwalker.github.io/2019/04/12/Method%E8%A7%A3%E8%AF%BB/">3. Method解读</a></p>
<p><a href="https://waitwalker.github.io/2019/04/15/Class%E8%A7%A3%E8%AF%BB/">4. Class解读</a></p>
<p><a href="https://waitwalker.github.io/2019/04/15/Ivar-objc-property-t-Protocol%E8%A7%A3%E8%AF%BB/">5. Ivar objc_property_t Protocol解读</a></p>
<p><a href="https://waitwalker.github.io/2019/04/18/Block%E8%A7%A3%E8%AF%BB/">6. Block解读</a></p>
<p><a href="http://waitwalker.cn/2019/04/22/Retain-Release解读/" target="_blank" rel="noopener">7. Retain&amp;Release解读</a></p>
<p><a href="http://waitwalker.cn/2019/04/23/Autorelease解读/" target="_blank" rel="noopener">8. Autorelease解读</a></p>
<p><a href="http://waitwalker.cn/2019/04/24/Weak解读/" target="_blank" rel="noopener">9. Weak解读</a></p>
<p><a href="http://waitwalker.cn/2019/04/25/msgSend-解读/" target="_blank" rel="noopener">10. msgSend()解读</a></p>

            </div>
            <hr>

            
            <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.88rem;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-large waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fa fa-close"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>
            

            <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">

<div id="article-share">
    
    <div class="social-share" data-disabled="qzone" data-wechat-qrcode-helper="<p>微信里点“发现”->“扫一扫”二维码便可查看分享。</p>"></div>
    
</div>

<script src="/libs/share/js/social-share.min.js"></script>

            <div class="reprint">
                <p>
                    <span class="reprint-tip">
                        <i class="fa fa-exclamation-circle"></i>&nbsp;&nbsp;转载请注明:
                    </span>
                    <a href="https://waitwalker.github.io" class="b-link-green">waitwalker</a>
                    <i class="fa fa-angle-right fa-lg fa-fw text-color"></i>
                    <a href="/2019/04/15/Class解读/" class="b-link-green">Class解读</a>
                </p>
            </div>
        </div>
    </div>

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6 overflow-policy" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fa fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/2019/04/15/Ivar-objc-property-t-Protocol解读/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/5.jpg" class="responsive-img" alt="Ivar objc_property_t Protocol解读">
                        
                        <span class="card-title">Ivar objc_property_t Protocol解读</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">群组欢迎加入群组,闲聊工作&amp;技术&amp;问题等

Ivar声明在objc-private.h文件中我们可以看到Ivar的声明结构:
typedef struct ivar_t *Ivar;
在objc-runtime-new.h中</div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="fa fa-clock-o fa-fw icon-date"></i>2019-04-15
                        </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/Runtime源码解读/" class="post-category" target="_blank">
                                    Runtime源码解读
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/Runtime/" target="_blank">
                        <span class="chip bg-color">Runtime</span>
                    </a>
                    
                    <a href="/tags/底层/" target="_blank">
                        <span class="chip bg-color">底层</span>
                    </a>
                    
                    <a href="/tags/源码/" target="_blank">
                        <span class="chip bg-color">源码</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6 overflow-policy" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fa fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2019/04/14/树/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/1.jpg" class="responsive-img" alt="树">
                        
                        <span class="card-title">树</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">群组欢迎加入群组,闲聊工作&amp;技术&amp;问题等

树的定义&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;一棵树(tree)是一些节点的集合.这个集合可以为空集.若这个集合非空,则一</div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="fa fa-clock-o fa-fw icon-date"></i>2019-04-14
                            </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/数据结构与算法/" class="post-category" target="_blank">
                                    数据结构与算法
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/数据结构/" target="_blank">
                        <span class="chip bg-color">数据结构</span>
                    </a>
                    
                    <a href="/tags/算法/" target="_blank">
                        <span class="chip bg-color">算法</span>
                    </a>
                    
                    <a href="/tags/Swift/" target="_blank">
                        <span class="chip bg-color">Swift</span>
                    </a>
                    
                    <a href="/tags/树/" target="_blank">
                        <span class="chip bg-color">树</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>
</div>


<script>
    $('#articleContent').on('copy', function (e) {
        // IE8 or earlier browser is 'undefined'
        if (typeof window.getSelection === 'undefined') return;

        var selection = window.getSelection();
        // if the selection is short let's not annoy our users.
        if (('' + selection).length < Number.parseInt('120')) {
            return;
        }

        // create a div outside of the visible area and fill it with the selected text.
        var bodyElement = document.getElementsByTagName('body')[0];
        var newdiv = document.createElement('div');
        newdiv.style.position = 'absolute';
        newdiv.style.left = '-99999px';
        bodyElement.appendChild(newdiv);
        newdiv.appendChild(selection.getRangeAt(0).cloneContents());

        // we need a <pre> tag workaround.
        // otherwise the text inside "pre" loses all the line breaks!
        if (selection.getRangeAt(0).commonAncestorContainer.nodeName === 'PRE') {
            newdiv.innerHTML = "<pre>" + newdiv.innerHTML + "</pre>";
        }

        var url = document.location.href;
        newdiv.innerHTML += '<br />'
            + '来源: waitwalker<br />'
            + '作者: waitwalker<br />'
            + '链接: <a href="' + url + '">' + url + '</a><br />'
            + '本文章著作权归作者所有，任何形式的转载都请注明出处。';

        selection.selectAllChildren(newdiv);
        window.setTimeout(function () {bodyElement.removeChild(newdiv);}, 200);
    });
</script>

    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title"><i class="fa fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fa fa-list"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            // headingsOffset: -205,
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).slideUp(500);
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).slideDown(500);
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>
    

</main>


<footer class="page-footer bg-color">
    <div class="container row center-align">
        <div class="col s12 m8 l8 copy-right">
            本站在原作者&copy;<a href="https://blinkfox.github.io/" target="_blank">Blinkfox</a>基于
            <a href="https://hexo.io/" target="_blank">Hexo</a> 的
            <a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">hexo-theme-matery</a>主题基础上搭建.

            

            
			
                <br>
                
                <span id="busuanzi_container_site_pv">
                    <i class="fa fa-heart-o"></i>
                    本站总访问量 <span id="busuanzi_value_site_pv" class="white-color"></span>
                </span>
                
                
                <span id="busuanzi_container_site_uv">
                    <i class="fa fa-users"></i>
                    次,&nbsp;访客数 <span id="busuanzi_value_site_uv" class="white-color"></span> 人.
                </span>
                
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis"><!---->
<a href="https://github.com/waitwalker" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
    <i class="fa fa-github"></i>
</a>

<a href="https://twitter.com/284485487" class="tooltipped" target="_blank" data-tooltip="Twitter联系我" data-position="top" data-delay="50">
    <i class="fa fa-twitter"></i>
</a>

<a href="https://www.facebook.com/profile.php?id=100003684945279" class="tooltipped" target="_blank" data-tooltip="Twitter联系我" data-position="top" data-delay="50">
    <i class="fa fa-facebook"></i>
</a>

<a href="https://t.me/joinchat/Ej0o0A1ntlq5ZFIMzzO5Pw" class="tooltipped" target="_blank" data-tooltip="Twitter联系我" data-position="top" data-delay="50">
    <i class="fa fa-telegram"></i>
</a>

<a href="https://www.weibo.com/1789419613/profile?topnav=1&wvr=6&is_all=1" class="tooltipped" target="_blank" data-tooltip="Twitter联系我" data-position="top" data-delay="50">
    <i class="fa fa-weibo"></i>
</a>


<!--原来-->
<!---->
    <!--<a href="mailto:waitwalker@163.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">-->
        <!--<i class="fa fa-envelope-open"></i>-->
    <!--</a>-->
<!---->

<!---->
    <!--<a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=284485487" class="tooltipped" data-tooltip="QQ联系我: 284485487" data-position="top" data-delay="50">-->
        <!--<i class="fa fa-qq"></i>-->
    <!--</a>-->
<!---->

<!---->
    <!--<a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">-->
        <!--<i class="fa fa-rss"></i>-->
    <!--</a>-->
<!----></div>
    </div>
</footer>

<div class="progress-bar"></div>


<!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fa fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字" class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
});
</script>
<!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fa fa-angle-up"></i>
    </a>
</div>


<script src="/libs/materialize/materialize.min.js"></script>
<script src="/libs/masonry/masonry.pkgd.min.js"></script>
<script src="/libs/aos/aos.js"></script>
<script src="/libs/scrollprogress/scrollProgress.min.js"></script>
<script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
<script src="/js/matery.js"></script>

<!-- Global site tag (gtag.js) - Google Analytics -->




    <script async src="/libs/others/busuanzi.pure.mini.js"></script>


</body>
</html>